package com.zf.springdoc.openapi3.controller.v1;

import com.zf.springdoc.openapi3.entity.Student;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Zhou Feng
 */
@RestController
@RequestMapping("/v1/hello")
@Tag(name = "hello API", description = "hhhhh")
public class HelloController {

    @Operation(summary = "测试接口", description = "测试接口说明")
    @GetMapping("/test")
    public Student test(@Parameter(name = "name", description = "名字") @RequestParam(name = "name") String name) {
        Student student = new Student();
        student.setName(name);
        return student;
    }


    @Operation(summary = "造接口", description = "说明")
    @GetMapping("/build")
    @Parameters(value = {
            @Parameter(name = "name", description = "名字"),
            @Parameter(name = "age", description = "年龄"),
    })
    public Student test(@RequestParam(name = "name") String name, @RequestParam(name = "age") Integer age) {
        Student student = new Student();
        student.setName(name);
        student.setAge(age);
        return student;
    }
}
